<%@ page language="java" contentType="text/html; charset=utf-8" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="bb" class="weaver.general.BaseBean"/>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%
    JSONObject jsonData = new JSONObject();
    rs.executeQuery("select id from uf_httz where htzt in (0,1,2,3,4)");
    int count = 0;
    while (rs.next()){
        String mainid = Util.null2String(rs.getString(1));
        updateFkjdbm(mainid);
        count++;
    }
    jsonData.put( "count", count );
    out.print( jsonData.toJSONString() );
%>
<%!
    public static void updateFkjdbm(String mainid){
        RecordSet rs = new RecordSet();
        rs.executeQuery( "select id from uf_httz_dt2 where mainid=? order by id", mainid);
        int count = 0;
        while (rs.next()){
            String id = Util.null2String(rs.getString("id"));
            rs.executeUpdate("update uf_httz_dt2 set fkjdbm='"+count+"' where mainid=? and id=? and ifnull(fkjdbm,-1) <0",mainid,id);
            count++;
        }
    }
%>